package com.dxy.lc.auth;

import com.dxy.lc.model.entity.User;
import org.springframework.stereotype.Component;

@Component
public class DefaultLoginUser implements LoginUser<User> {

    private User loginUser;

    public DefaultLoginUser() {
    }

    public DefaultLoginUser(User loginUser) {
        this.loginUser = loginUser;
    }

    @Override
    public User getEntity() {
        return this.loginUser;
    }

    @Override
    public String getUserId() {
        return loginUser.getId().toString();
    }

    @Override
    public String getUserName() {
        return loginUser.getUsername();
    }

    @Override
    public boolean isAdmin() {
        return loginUser.isAdmin();
    }
}
